package com.dayu.web.controller.share;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dayu.common.annotation.Log;
import com.dayu.common.core.controller.BaseController;
import com.dayu.common.core.domain.AjaxResult;
import com.dayu.common.enums.BusinessType;
import com.dayu.share.domain.ShareGoodsSpecsValues;
import com.dayu.share.service.IShareGoodsSpecsValuesService;
import com.dayu.common.utils.poi.ExcelUtil;
import com.dayu.common.core.page.TableDataInfo;

/**
 * 规格内容Controller
 * 
 * @author HK
 * @date 2021-04-08
 */
@RestController
@RequestMapping("/share/values")
public class ShareGoodsSpecsValuesController extends BaseController
{
    @Autowired
    private IShareGoodsSpecsValuesService shareGoodsSpecsValuesService;

    /**
     * 查询规格内容列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ShareGoodsSpecsValues shareGoodsSpecsValues)
    {
        startPage();
        List<ShareGoodsSpecsValues> list = shareGoodsSpecsValuesService.selectShareGoodsSpecsValuesList(shareGoodsSpecsValues);
        return getDataTable(list);
    }

    /**
     * 导出规格内容列表
     */
    @PreAuthorize("@ss.hasPermi('share:values:export')")
    @Log(title = "规格内容", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ShareGoodsSpecsValues shareGoodsSpecsValues)
    {
        List<ShareGoodsSpecsValues> list = shareGoodsSpecsValuesService.selectShareGoodsSpecsValuesList(shareGoodsSpecsValues);
        ExcelUtil<ShareGoodsSpecsValues> util = new ExcelUtil<ShareGoodsSpecsValues>(ShareGoodsSpecsValues.class);
        return util.exportExcel(list, "values");
    }

    /**
     * 获取规格内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('share:values:query')")
    @GetMapping(value = "/{valuesId}")
    public AjaxResult getInfo(@PathVariable("valuesId") Long valuesId)
    {
        return AjaxResult.success(shareGoodsSpecsValuesService.selectShareGoodsSpecsValuesById(valuesId));
    }

    /**
     * 新增规格内容
     */
    @PreAuthorize("@ss.hasPermi('share:values:add')")
    @Log(title = "规格内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShareGoodsSpecsValues shareGoodsSpecsValues)
    {
        return toAjax(shareGoodsSpecsValuesService.insertShareGoodsSpecsValues(shareGoodsSpecsValues));
    }

    /**
     * 修改规格内容
     */
    @PreAuthorize("@ss.hasPermi('share:values:edit')")
    @Log(title = "规格内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShareGoodsSpecsValues shareGoodsSpecsValues)
    {
        return toAjax(shareGoodsSpecsValuesService.updateShareGoodsSpecsValues(shareGoodsSpecsValues));
    }

    /**
     * 删除规格内容
     */
    @PreAuthorize("@ss.hasPermi('share:values:remove')")
    @Log(title = "规格内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{valuesIds}")
    public AjaxResult remove(@PathVariable Long[] valuesIds)
    {
        return toAjax(shareGoodsSpecsValuesService.deleteShareGoodsSpecsValuesByIds(valuesIds));
    }
}
